iOS 5 Programming Pushing the Limits by Rob Napier & Mugunth Kumar
Author:Rob Napier & Mugunth Kumar
Language: eng
Format: epub
Publisher: Wiley
Published: 2011-11-21T16:00:00+00:00
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:LOGIN_URL]];
[request setUsername:loginName];
[request setPassword:password];
[request setDelegate:self];
[request setDidFinishSelector:@selector(loginDone:)];
[request setDidFailSelector:@selector(loginFailed:)];
[self.networkQueue addOperation:request];
return self;
}
That completes your web service call. Now you should notify the caller, (which is usually the view controller) about the outcome of the web service call. You will use delegates for this.
Adding Delegates to the RESTEngine
For every web service call this RESTEngine class exposes two delegate methods, one for notifying a successful call and another for error notification. Usually this delegate is implemented by the view controller that calls the methods in the RESTEngine.
Another, arguably cleaner way to notify the caller is by using blocks. Blocks have their own advantages and drawbacks, as discussed in Chapter 16, which also covers when to use blocks and when to use delegates. In that chapter, you modify this RESTEngine to return data and errors using blocks.
1. Use the following code to add a delegate definition to your RESTEngine class:
Code showing the delegate in RESTEngine.h
@protocol RESTEngineDelegate <NSObject>
@optional
-(void) loginSucceeded:(NSString*) accessToken;
-(void) loginFailedWithError:(NSError*) error;
@end
Download
iOS 5 Programming Pushing the Limits by Rob Napier & Mugunth Kumar.epub
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7767)
Filmora Efficient Editing by Alexander Zacharias(5790)
The Infinite Retina by Robert Scoble Irena Cronin(5271)
Learn Wireshark - Fundamentals of Wireshark. by Lisa Bock(3981)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3935)
Edit Like a Pro with iMovie by Regit(3431)
Linux Administration Best Practices by Scott Alan Miller(2858)
Linux Command Line and Shell Scripting Techniques by Vedran Dakic & Jasmin Redzepagic(2836)
MCSA Windows Server 2016 Study Guide: Exam 70-740 by William Panek(2521)
Mastering PowerShell Scripting - Fourth Edition by Chris Dent(2405)
Docker on Windows by Stoneman Elton(2319)
Kali Linux - An Ethical Hacker's Cookbook: End-to-end penetration testing solutions by Sharma Himanshu(2315)
Creative Projects for Rust Programmers by Carlo Milanesi(2255)
Hands-On AWS Penetration Testing with Kali Linux by Karl Gilbert(2109)
Hands-On Linux for Architects by Denis Salamanca(2052)
Programming in C (4th Edition) (Developer's Library) by Stephen G. Kochan(2005)
Computers For Seniors For Dummies by Nancy C. Muir(2001)
The Old New Thing by Raymond Chen(1941)
Linux Kernel Debugging by Kaiwan N Billimoria(1762)
